<!-- 卡片 -->
<template>
  <div class="Card-container">
    <div class="head">
      <TitleBar title="宿舍楼一览"></TitleBar>
    </div>
    <div class="mains" v-if="readUserInfo.manageArr.length">
      <div
        class="items"
        v-for="(item, index) in readUserInfo.manageArr"
        :key="item.id"
      >
        <div class="title">
          <span>NO.{{ index + 1 }}</span
          ><span>{{ item.DormitoryName }}</span>
        </div>
        <div class="describe">
          <div class="main">
            <div class="item">
              <span>楼层数</span><span>:</span
              ><span class="num">{{ item.floorNum }}</span>
            </div>
            <div class="item">
              <span>房间数</span><span>:</span
              ><span class="num">{{ item.roomNum*item.floorNum }}</span>
            </div>
            <div class="item">
              <span>学生数</span><span>:</span
              ><span class="num">{{ item.dormitoryresided }}</span>
            </div>
          </div>
        </div>
        <div class="fun">
          <div class="item">
            <slot name="one" :data="item"></slot>
          </div>
          <div class="item">
            <slot name="two" :data="item"></slot>
          </div>
          <div class="item">
            <slot name="three" :data="item"></slot>
          </div>
        </div>
      </div>
    </div>
    <div class="unavailable" v-else>
      <BackgorundBox>
        <Unavailable></Unavailable>
      </BackgorundBox>
    </div>
  </div>
</template>


<script setup>
import TitleBar from "@/components/TitleBar/index.vue";
import Unavailable from "@/components/Unavailable/index.vue"
import BackgorundBox from "@/components/BackgroundBox/index.vue"
import { useUserStore } from "@/store/useUserStore.js";
import { storeToRefs } from "pinia";
const { readUserInfo } = storeToRefs(useUserStore());
</script>

<style lang="less" scoped>
@import "@/styles/var.less";
@about: 20px;
.Card-container {
  width: 100%;
  height: 100%;
  .mains {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px 30px;
    padding-bottom:30px;
  }
  .items {
    width: 100%;
    position: relative;
  }
  .title {
    border-radius: 5px 5px 0 0;
    width: 100%;
    height: 50px;
    line-height: 50px;
    background-color: @primary;
    color: @white;
    font-size: 1.2em;
    font-weight: bold;
    padding: 0 @about;
    span {
      margin-right: 5px;
    }
  }
  .describe {
    border-radius: 0 0 5px 5px;
    width: 100%;
    height: 100px;
    background-color: @white;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 0 @about;
    .main {
      height: 80%;
    }
    .item {
      font-size: 1em;
      margin: 4px 0;
      color: @second;
      span {
        margin-right: 5px;
      }
      .num {
        font-weight: 600;
      }
    }
  }
  .fun {
    position: absolute;
    right: 30px;
    top: 40px;
    display: flex;
    .item {
      margin: 0 10px;
    }
  }
  .back-container{
      width: 100%;
      min-height: 150px;
    }

}
</style>